//
//  LoginViewController.swift
//  XmppTry
//
//  Created by Arthur on 15/12/16.
//  Copyright © 2015年 Arthur. All rights reserved.
//

import UIKit

class LoginViewController: UIViewController {

    @IBOutlet weak var autologinSwitch: UISwitch!
    @IBOutlet weak var doneButton: UIBarButtonItem!
    @IBOutlet weak var userTF: UITextField!
    
    @IBOutlet weak var pswTF: UITextField!
    
    @IBOutlet weak var serverTF: UITextField!
    
    
    var requireLogin = false
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

   
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if sender as! UIBarButtonItem == self.doneButton{
            
            NSUserDefaults.standardUserDefaults().setObject(userTF.text, forKey: "weixinID")
            NSUserDefaults.standardUserDefaults().setObject(pswTF.text, forKey: "weixinPwd")
            NSUserDefaults.standardUserDefaults().setObject(serverTF.text, forKey: "wxserver")
            
            NSUserDefaults.standardUserDefaults().setBool(self.autologinSwitch.on, forKey: "wxautologin")
            //同步用户配置
        
            NSUserDefaults.standardUserDefaults().synchronize()
            
            
            //需要登录
            requireLogin = true
        }
        
        
    }


}
